# data_object是poly_data #️⃣
from typing import Dict
from CloudEngine.Math.Vector3 import Vector3
from CloudEngine.core.VAttribute import VAttribute


def parse_attributes(data_object) -> Dict:
    attrs_dict = {}
    # 点属性
    point_data = data_object.GetPointData()
    if point_data:
        for i in range(point_data.GetNumberOfArrays()):
            array = point_data.GetArray(i)
            attr_name = array.GetName()
            size = array.GetNumberOfComponents()
            # ️ #️⃣ 如果是矢量
            if size == 3:
                float_array = point_data.GetArray(attr_name)
                attr = VAttribute(attr_name, float_array, size)
                attrs_dict[attr_name] = attr
            # ️ #️⃣ 如果是标量
            if size == 1:
                float_array = point_data.GetArray(attr_name)
                attr = VAttribute(attr_name, float_array, size)
                attrs_dict[attr_name] = attr
    return attrs_dict
